<?php
/**
 * 用户管理控制器
 *
 * @package    app
 * @version    1.0
 * @author     Ray 33705910@qq.com
 * @license    MIT License
 * @copyright  2013 - 2015 Ray
 * @link       http://wangxiaolei.cn
 */

/**
 * 本控制器主要用于：
 * 1.
 * @package  app
 * @extends  Controller
 */
namespace admin;

class Controller_User extends \Controller_BaseController{

	public $template = 'ace/template';

	public function before(){
        parent::before();
    }

	public function action_index(){
		$params = array(
            'title' => '用户列表',
            'menu' => 'user',
            'action_name' => '用户管理 》用户列表'
        );

        $items =  \Auth\Model\Auth_User::query();

        $count = $items->count();
        $config = array(
            'pagination_url' => "/admin/user",
            'total_items'    => $count,
            'per_page'       => \Input::get('count', 15),
            'uri_segment'    => "start",
            'show_first'     => true,
            'show_last'      => true,
            'name'           => 'bootstrap3_cn'
        );

        $pagination = new \Pagination($config);
        $params['pagination'] = $pagination;        
        $params['items'] = $items
                            ->rows_offset($pagination->offset)
                            ->rows_limit($pagination->per_page)
                            ->get();
        

        $params['groups'] = \Auth\Model\Auth_Group::query()
            ->get();

        \View::set_global($params);
        $this->template->content = \View::forge("ace/user/index");
	}

    public function action_group(){
        $params = array(
            'title' => '用户组列表',
            'menu' => 'user',
            'action_name' => '用户管理 》用户组列表'
        );

        $items =  \Auth\Model\Auth_Group::query();

        $count = $items->count();
        $config = array(
            'pagination_url' => "/admin/user",
            'total_items'    => $count,
            'per_page'       => \Input::get('count', 15),
            'uri_segment'    => "start",
            'show_first'     => true,
            'show_last'      => true,
            'name'           => 'bootstrap3_cn'
        );

        $pagination = new \Pagination($config);
        $params['pagination'] = $pagination;        
        $params['items'] = $items
                            ->rows_offset($pagination->offset)
                            ->rows_limit($pagination->per_page)
                            ->get();

        \View::set_global($params);
        $this->template->content = \View::forge("ace/user/group");
    }
}